home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / gfx / 3d / MyMPEG_gui.lha / MyMPEG_gui / MyMPEG.gui-3.3 < prev    next >
Text File  |  1997-04-23  |  25KB  |  698 lines

  1. (
  2. ( MyMPEG - create MPEG-animations with a GUI
  3. (          © Marc Bartels 12.02.97 first invention
  4. (          $VER: MyMPEG 1.1 for Real3D v3.3 (23 Apr 1997)
  5.  
  6. ?& MyMPEG_GUI NOT ?IF
  7. ( define MyMPEG_GUI to make sure that these will not be defined again later.
  8.  
  9. 1 CONSTANT MyMPEG_GUI
  10.  
  11. ( this file contains necessary RPL definitions for GUI words.
  12.  
  13. "r3d3:rpl/sys/ui.rpl" LOAD
  14. "r3d3:rpl/sys/io.rpl" LOAD
  15. "r3d3:rpl/sys/view.rpl" LOAD
  16. "r3d3:rpl/sys/windows.rpl" LOAD
  17. "r3d3:rpl/sys/render.rpl" LOAD
  18. "r3d3:rpl/sys/animation.rpl" LOAD
  19.  
  20. ( Variables, make sure these are unique. Conflicts with other RPL gui
  21. ( programs can crash the system.
  22.  
  23. 256 STRING   sDefPic
  24. 256 STRING   sDefMPEG
  25. 256 STRING   sDefMPEG2
  26. 256 STRING   sDefPlayer
  27. 256 STRING   sBuff
  28. 30  STRING   sBuff1
  29. 30  STRING   sBuff2
  30.     VARIABLE mympegaWindow
  31.     VARIABLE mympegaCheck1
  32.     VARIABLE mympegaCheck2
  33.     VARIABLE iCheck
  34.     VARIABLE mympegaMx1
  35.     VARIABLE mympegaStrX
  36.     VARIABLE mympegaStrY
  37.     VARIABLE mympegiStrX
  38.     VARIABLE mympegiStrY
  39.     VARIABLE mympegaMx2
  40. 30  STRING   mympegsStrI
  41. 30  STRING   mympegsStrP
  42. 30  STRING   mympegsStrB
  43. 30  STRING   mympegsStrV
  44.     VARIABLE mympegaPat
  45. 30  STRING   mympegsPat
  46.     VARIABLE mympegaStrV
  47.     VARIABLE mympegaView
  48.     VARIABLE mympegaMx3
  49. 256 STRING   mympegsPPath
  50. 256 STRING   mympegsPName
  51. 256 STRING   mympegsPFull
  52.     VARIABLE iCount
  53.     VARIABLE mympegaPic
  54.     VARIABLE mympegaPB
  55.     VARIABLE mympegiX
  56.     VARIABLE mympegaFile
  57. 256 STRING   mympegsMFull
  58.     VARIABLE mympegaMPG
  59.     VARIABLE mympegaMB
  60.     VARIABLE mympegaSB
  61.     VARIABLE mympegaCB
  62.     VARIABLE iStartFrm
  63.     VARIABLE iGOP
  64.     VARIABLE iOutput
  65. 30  STRING   sFrmCmd
  66.  
  67. ( ############################################################ )
  68. ( ##########  Change the following to your needs: ############ )
  69.  
  70. 15                                       CONSTANT FONTSIZE
  71. "RAM:t/preview."                                  sDefPic    CPY
  72. "ram:"                                            sDefMPEG   CPY
  73. "rEaL:anim/"                                      sDefMPEG2  CPY
  74. "dh0:viewer/mpeg_play dither cybergfx loop quiet" sDefPlayer CPY
  75.  
  76. ( ############################################################ )
  77.  
  78. ( Callbacks for buttons. When the user clicks buttons, these words are called.
  79. ( and other Word definitions.
  80.  
  81. : mympegcbCheck1  ( simulates a radiobutton, first knop
  82.     IF
  83.         UI_Done 0 UICB_Checked  mympegaCheck2 FETCH UI_SETATTRS
  84.     ELSE
  85.         UI_Done 1 UICB_Checked  mympegaCheck1 FETCH UI_SETATTRS
  86.     ENDIF
  87. ;
  88.  
  89. : mympegcbCheck2  ( simulates a radiobutton, second knop
  90.     IF
  91.         UI_Done 0 UICB_Checked  mympegaCheck1 FETCH UI_SETATTRS
  92.     ELSE
  93.         UI_Done 1 UICB_Checked  mympegaCheck2 FETCH UI_SETATTRS
  94.     ENDIF
  95. ;
  96.  
  97. : SetPicSize  ( writes the framesize into the Rendersettings of the relevant View window
  98.               ( because the RPL-includes for Amiga v3.5 does not yet exist numeral values are used
  99.     mympegiStrY FETCH
  100.     mympegsStrV WND_ADDR  W.aData + FETCH
  101.     1106 ( VR.bHeight at first h then w ) + STORE
  102.     mympegiStrX FETCH
  103.     mympegsStrV WND_ADDR  W.aData + FETCH
  104.     1104 ( VR.bWidth ) + STORE
  105. ;
  106.  
  107. : mympegcbMx1  ( Cyclegadget to choose framesize, here without polling from array, old version
  108.     DUP 0 = IF
  109.         128 mympegiStrX STORE
  110.         96  mympegiStrY STORE
  111.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  112.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  113.     ENDIF
  114.     DUP 1 = IF
  115.         160 mympegiStrX STORE
  116.         112  mympegiStrY STORE
  117.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  118.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  119.     ENDIF
  120.     DUP 2 = IF
  121.         160 mympegiStrX STORE
  122.         128  mympegiStrY STORE
  123.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  124.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  125.     ENDIF
  126.     DUP 3 = IF
  127.         352 mympegiStrX STORE
  128.         240  mympegiStrY STORE
  129.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  130.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  131.     ENDIF
  132.     DUP 4 = IF
  133.         320 mympegiStrX STORE
  134.         256  mympegiStrY STORE
  135.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  136.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  137.     ENDIF
  138.     5 = IF
  139.         UI_Done 0 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  140.         UI_Done 0 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  141.         UI_Done sBuff UIST_String mympegaStrX FETCH UI_GETATTRS
  142.         sBuff ATOF mympegiStrX STORE
  143.         UI_Done sBuff UIST_String mympegaStrY FETCH UI_GETATTRS
  144.         sBuff ATOF mympegiStrY STORE
  145.     ELSE
  146.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  147.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  148.     ENDIF
  149.     SetPicSize
  150. ;
  151.  
  152. : mympegcbStrX  ( X value for framesize is truncated to a multiple of 16
  153.     ATOF 16 / 16 * mympegiStrX STORE
  154.     UI_Done mympegiStrX FETCH "%d" sBuff SPRINTF sBuff UIST_String mympegaStrX FETCH UI_SETATTRS
  155.     SetPicSize
  156. ;
  157.  
  158. : mympegcbStrY  ( see at X value
  159.     ATOF 16 / 16 * mympegiStrY STORE
  160.     UI_Done mympegiStrY FETCH "%d" sBuff SPRINTF sBuff UIST_String mympegaStrY FETCH UI_SETATTRS
  161.     SetPicSize
  162. ;
  163.  
  164. : CheckPat  ( the given pattern is validated at begining and end
  165.             ( letters in the middle are not checked
  166.     "|n" sBuff SPRINTF
  167.     sBuff mympegsPat 1 NCPY
  168.     sBuff "I" COMPARE IF
  169.         "Has to begin with I " ERROR
  170.         EXIT
  171.     ENDIF
  172.     mympegsPat DUP LEN 1 - + sBuff SWAP 1 NCPY sBuff "B" COMPARE NOT IF
  173.         "Must not end with B " ERROR
  174.         EXIT
  175.     ENDIF
  176. ;
  177.  
  178. : mympegcbMx2  ( get values for pattern from array
  179.                ( only possible by using an external rpl file
  180.    DUP 4 = IF
  181.        DROP
  182.        UI_Done 0 UI_Disabled mympegaPat FETCH UI_SETATTRS
  183.        UI_Done mympegsPat UIST_String mympegaPat FETCH UI_GETATTRS
  184.    ELSE
  185.        UI_Done 1 UI_Disabled mympegaPat FETCH UI_SETATTRS
  186.        ( mympegLab2 SWAP PFETCH mympegsPat CPY
  187.        "r3d3:rpl/MyMPEG-array-Pat.rpl" LOAD
  188.    ENDIF
  189. ;
  190.  
  191. : mympegcbPat
  192.     mympegsPat SPRINTF
  193.     CheckPat
  194. ;
  195.  
  196. : mympegcbStrI
  197.     DUP ATOF DUP 1 < SWAP 31 > OR IF
  198.         "The value must be between 1 and 31 !" ERROR
  199.         DROP
  200.     ELSE
  201.         mympegsStrI SPRINTF
  202.     ENDIF
  203. ;
  204.  
  205. : mympegcbStrB
  206.     DUP ATOF DUP 1 < SWAP 31 > OR IF
  207.         "The value must be between 1 and 31 !" ERROR
  208.         DROP
  209.     ELSE
  210.         mympegsStrB SPRINTF
  211.     ENDIF
  212. ;
  213.  
  214. : mympegcbStrP
  215.     DUP ATOF DUP 1 < SWAP 31 > OR IF
  216.         "The value must be between 1 and 31 !" ERROR
  217.         DROP
  218.     ELSE
  219.         mympegsStrP SPRINTF
  220.     ENDIF
  221. ;
  222.  
  223. : SetPicName  ( writes the picturename into the Rendersettings of the relevant View window
  224.               ( because the RPL-includes for Amiga v3.5 does NOT yet exist numeral values are used
  225.     mympegsStrV WND_ADDR  W.aData + FETCH
  226.     1176 ( VR.sFilename ) + mympegsPFull SWAP CPY
  227. ;
  228.  
  229. : PathParts   ( devide the full name into file and path name
  230.               ( has to be executed after StripPath, due to the right iCount value
  231.     "" mympegsPPath SPRINTF
  232.     mympegsPPath mympegsPFull DUP LEN iCount FETCH - NCAT
  233.     iCount FETCH 1 - iCount STORE
  234.     mympegsPFull DUP LEN iCount FETCH - +
  235.     mympegsPName CPY
  236. ;
  237.  
  238. : StripPath  ( validate picturename and determine iCount for later separation
  239.     mympegsPFull DUP LEN 1 - + "/" COMPARE NOT IF      ( check if it ends with /
  240.         "Name ends with / !" ERROR
  241.         EXIT
  242.     ENDIF
  243.     1 iCount STORE
  244.     "|n" sBuff SPRINTF
  245.     BEGIN  ( LOOP UNTIL first / is reached reverse
  246.         mympegsPFull DUP LEN iCount FETCH - + sBuff SWAP 1 NCPY sBuff "/" COMPARE NOT IF
  247.             EXIT
  248.         ENDIF
  249.         mympegsPFull LEN iCount FETCH < IF  ( end the LOOP IF ...
  250.             "Use at least one subdirectory !" ERROR
  251.             EXIT
  252.         ENDIF
  253.         iCount FETCH 1 + iCount STORE
  254.     AGAIN
  255. ;
  256.  
  257. : COUNTWND
  258.  
  259. 0                   ( INITILIATE COUNTER
  260. "editor" DATABASE   ( GET POINTER TO STRUCTURE
  261. BEGIN               ( START LOOP
  262.     FETCH           ( GET ENTRY
  263.     DUP FETCH       ( GET NEXT ENTRY
  264. WHILE               ( IF STRUCTURE VALID
  265.       SWAP 1 + SWAP ( INCREASE COUNTER
  266. REPEAT              ( RETURN LOOP
  267. DROP                ( DROP ADDRESS OF STRUCTURE
  268. ;
  269.  
  270. : CountView  ( determine the number of View windows
  271.              ( SuperBitMap, Borderless OR DoubleBuffered are not counted
  272.              ( output integer
  273.     0
  274.     "editor" DATABASE
  275.     COUNTWND 0 DO
  276.         FETCH DUP W.iType + FETCH 3 = IF
  277.             SWAP 1 + SWAP
  278.         ENDIF
  279.     LOOP
  280.     DROP
  281. ;
  282.  
  283. : CycleView  ( puts the names of available View windows out
  284.     1 iCount STORE
  285.     "editor" DATABASE
  286.     BEGIN
  287.         FETCH DUP
  288.         W.iType + FETCH 3 = IF
  289.             DUP
  290.             W.aName + FETCH SWAP ( PUTS
  291.         ENDIF
  292.         iCount FETCH COUNTWND > IF DROP EXIT ENDIF
  293.         iCount FETCH 1 + iCount STORE
  294.     AGAIN
  295. ;
  296.  
  297. : mympegcbMx3  ( Cyclegadget for View window selection
  298.                ( here an external rpl file is used also to read from the array
  299.     DUP 0 = IF
  300.         DROP
  301.         UI_Done 1 UI_Disabled mympegaPic FETCH UI_SETATTRS
  302.         UI_Done 1 UI_Disabled mympegaPB FETCH UI_SETATTRS
  303.         UI_Done 1 UI_Disabled mympegaMPG FETCH UI_SETATTRS
  304.         UI_Done 1 UI_Disabled mympegaMB FETCH UI_SETATTRS
  305.         UI_Done 1 UI_Disabled mympegaSB FETCH UI_SETATTRS
  306.     ELSE
  307.         "r3d3:rpl/MyMPEG-array-View.rpl" LOAD
  308.         UI_Done 0 UI_Disabled mympegaPic FETCH UI_SETATTRS
  309.         UI_Done 0 UI_Disabled mympegaPB FETCH UI_SETATTRS
  310.         UI_Done 0 UI_Disabled mympegaMPG FETCH UI_SETATTRS
  311.         UI_Done 0 UI_Disabled mympegaMB FETCH UI_SETATTRS
  312.         UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  313.  
  314.         mympegsStrV  "attr(W:%s->output)" sBuff SPRINTF  sBuff EVAL iOutput STORE  ( save original outputmode
  315.         mympegsStrV  "attr(W:%s->output)=6" sBuff SPRINTF  sBuff EVAL DROP         ( set output to PPM
  316.         mympegsStrV  "attr(W:%s->filename)" sBuff SPRINTF  sBuff EVAL DUP "" COMPARE  0  =  IF
  317.             DROP sDefPic
  318.         ENDIF
  319.         DUP mympegsPFull CPY
  320.         UI_Done SWAP UIST_String mympegaPic FETCH UI_SETATTRS
  321.         SetPicSize
  322.         SetPicName
  323.         StripPath
  324.         PathParts
  325.         sDefMPEG mympegsPName "%s%smpg" mympegsMFull SPRINTF
  326.         UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  327.     ENDIF
  328.  
  329. ;
  330.  
  331. : mympegcbPic  ( after typing the picturename the MPEG name is changed automatically
  332.     DROP
  333.     UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_GETATTRS
  334.     SetPicName
  335.     StripPath
  336.     PathParts
  337.     sDefMPEG mympegsPName "%s%smpg" mympegsMFull SPRINTF
  338.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  339. ;
  340.  
  341. : mympegcbGetP  ( filerequester for picturenames
  342.     UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_GETATTRS
  343.     iIO_SAVE mympegsPFull mympegsPPath "Base picturename" GET_FIL
  344.     IF
  345.         UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_SETATTRS
  346.     ELSE
  347.         UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_GETATTRS
  348.     ENDIF
  349.     SetPicName
  350.     StripPath
  351.     PathParts
  352.     sDefMPEG mympegsPName "%s%smpg" mympegsMFull SPRINTF
  353.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  354. ;
  355.  
  356. : Frames  ( outputs framename without path but with framenumbers - from to - in the right way
  357.     "|n" sBuff SPRINTF
  358.     mympegsPName
  359.     "" "attr(A:->currentfrm)" EVAL "attr(A:->format)" EVAL sBuff1 SPRINTF sBuff1
  360.     "" "attr(A:->frames)" EVAL 1 - "attr(A:->format)" EVAL sBuff2 SPRINTF sBuff2
  361.     "%s*      [%s-%s]" sBuff SPRINTF
  362. ;
  363.  
  364. : mympegcbMPG  ( reads the MPEG name
  365.     DROP
  366.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_GETATTRS
  367. ;
  368.  
  369. : mympegcbGetM  ( filerequester for MPEG name
  370.     "|n" mympegsMFull SPRINTF
  371.     iIO_SAVE mympegsMFull sDefMPEG2 "Name of MPEG" GET_FIL
  372.     IF
  373.         UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  374.     ( ELSE
  375.     (    UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_GETATTRS
  376.     ENDIF
  377. ;
  378.  
  379. : FCGOPs  ( FrameCommand when GOPs are used
  380.     DUP "attr(A:->currentfrm)" EVAL SWAP - 1 + mympegsPat LEN MOD NOT IF
  381.         iGOP FETCH
  382.         mympegsPFull "r3d3:Accessories/mpeg_encodes -gop %d %sPARAM" sBuff SPRINTF sBuff SYSTEM
  383.         mympegsMFull iGOP FETCH "c:protect %s.gop.%d d sub >nil:" sBuff SPRINTF sBuff SYSTEM
  384.         mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  385.         iGOP FETCH 1 + iGOP STORE
  386.     ELSE
  387.         "attr(A:->currentfrm)" EVAL 1 + "attr(A:->frames)" EVAL = IF
  388.             iGOP FETCH mympegsPFull "r3d3:Accessories/mpeg_encodes -gop %d %sPARAM" sBuff SPRINTF sBuff SYSTEM
  389.             mympegsMFull iGOP FETCH "c:protect %s.gop.%d d sub >nil:" sBuff SPRINTF sBuff SYSTEM
  390.             mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  391.         ENDIF
  392.     ENDIF
  393.     "attr(A:->currentfrm)" EVAL 1 + "attr(A:->frames)" EVAL = IF
  394.         DROP     ( the offset for GOPs is droped
  395.         mympegsPFull "r3d3:Accessories/mpeg_encodes -combine_gops %sPARAM" sBuff SPRINTF sBuff SYSTEM
  396.         mympegsMFull "c:delete %s.gop.#? force >nil:" sBuff SPRINTF sBuff SYSTEM
  397.         mympegsPFull "c:delete %sPARAM force >nil:" sBuff SPRINTF sBuff SYSTEM
  398.         UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  399.         UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  400.         sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  401.     ENDIF
  402. ;
  403.  
  404. : FCnoGOPs ( FrameCommand when GOPs are not used
  405.     "attr(A:->currentfrm)" EVAL 1 + "attr(A:->frames)" EVAL = IF
  406.         mympegsPFull "r3d3:Accessories/mpeg_encodes %sPARAM" sBuff SPRINTF sBuff SYSTEM
  407.         mympegsPFull "c:delete %sPARAM force >nil:" sBuff SPRINTF sBuff SYSTEM
  408.         UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  409.         UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  410.         sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  411.         "OK|No" "Delete the picture files?" GET_KEY
  412.         IF
  413.             mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  414.         ENDIF
  415.         QUIT
  416.     ENDIF
  417.  
  418. ;
  419.  
  420. : DumpStrNL ( Input: sString
  421.             ( saves row with CR and LF to file
  422.     mympegaFile FETCH FPUTS 0 < IF
  423.         "Cannot write to a file" ERROR
  424.     ENDIF
  425.     "|n" sBuff SPRINTF
  426.     sBuff mympegaFile FETCH FPUTS 0 < IF
  427.         "Cannot write to a file" ERROR
  428.     ENDIF
  429. ;
  430.  
  431. : mympegcbStart ( start button hit
  432.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  433.     DEPTH IF         ( if Pause was hit
  434.         ( do nothing
  435.     ELSE
  436.         "|n" sFrmCmd SPRINTF
  437.         "anim" DATABASE A.sFRAMECMD + sFrmCmd CPY                                  ( save originale framecommand
  438.         mympegsStrV  "attr(W:%s->output)=6" sBuff SPRINTF  sBuff EVAL DROP         ( set outputmode to PPM
  439.         SetPicSize
  440.  
  441.         ( mympegsPFull "%sparam" sBuff SPRINTF sBuff "w" FOPEN DUP mympegaFile STORE  ( open PARAM file
  442.         ( NOT IF
  443.         (     sBuff "Cannot open file %s - START AGAIN" PUTS
  444.         (     mympegsPFull "protect %sparam d add" sBuff SPRINTF sBuff SYSTEM
  445.         (     EXIT
  446.         ( ENDIF
  447.  
  448.         "para" mympegsPFull "%sparam" sBuff SPRINTF sBuff RX_SETCLIP
  449.  
  450.         ( "# This parameter file was created by MyMPEG. " DumpStrNL
  451.         ( "# A RPL program to CREATE MPEGs from within Real3D v3.5 " DumpStrNL
  452.         ( "# Written by Marc Bartels " DumpStrNL
  453.         ( "" DumpStrNL
  454.         ( "" DumpStrNL
  455.         "patt" mympegsPat
  456.         "PATTERN          %s" sBuff SPRINTF sBuff RX_SETCLIP
  457.         "mfull" mympegsMFull
  458.         "OUTPUT           %s" sBuff SPRINTF sBuff RX_SETCLIP
  459.         ( "" DumpStrNL
  460.         ( "BASE_FILE_FORMAT PNM" DumpStrNL
  461.         "gopsize" mympegsPat LEN
  462.         "GOP_SIZE         %d" sBuff SPRINTF sBuff RX_SETCLIP
  463.         "slices" mympegiStrY FETCH 16 /
  464.         "SLICES_PER_FRAME %d" sBuff SPRINTF sBuff RX_SETCLIP
  465.         ( "" DumpStrNL
  466.         ( "PIXEL            HALF" DumpStrNL
  467.         ( "RANGE            10" DumpStrNL
  468.         ( "PSEARCH_ALG      LOGARITHMIC" DumpStrNL
  469.         ( "BSEARCH_ALG      CROSS2" DumpStrNL
  470.         "iscale" mympegsStrI
  471.         "IQSCALE          %s" sBuff SPRINTF sBuff RX_SETCLIP
  472.         "bscale" mympegsStrB
  473.         "BQSCALE          %s" sBuff SPRINTF sBuff RX_SETCLIP
  474.         "pscale" mympegsStrP
  475.         "PQSCALE          %s" sBuff SPRINTF sBuff RX_SETCLIP
  476.         ( "" DumpStrNL
  477.         ( "REFERENCE_FRAME  ORIGINAL" DumpStrNL
  478.         ( "FORCE_ENCODE_LAST_FRAME" DumpStrNL                        ( undocumented feature
  479.         "size" mympegiStrX FETCH mympegiStrY FETCH
  480.         "YUV_SIZE         %dx%d" sBuff SPRINTF sBuff RX_SETCLIP
  481.         "ppath" mympegsPPath
  482.         "INPUT_DIR        %s" sBuff SPRINTF sBuff RX_SETCLIP
  483.         ( "INPUT" DumpStrNL
  484.         "frames" Frames                sBuff RX_SETCLIP
  485.         ( "END_INPUT" DumpStrNL
  486.         ( "INPUT_CONVERT    *" DumpStrNL
  487.  
  488.         ( mympegaFile FETCH FCLOSE                                            ( close file
  489.         ( IF "ERROR closing file " ERROR EXIT ENDIF
  490.  
  491.         "ADDRESS COMMAND \"rx r3d3:rexx/MyMPEGparam.rexx\"" RX
  492.  
  493.         mympegsPFull "protect %sPARAM d sub" sBuff SPRINTF sBuff SYSTEM
  494.  
  495.         0 3 6 0 MENUNUM iWC_MENU mympegsStrV iWM_ACTION WND_SENDMSG DROP  ( open Drawing Settings of View window
  496.         
  497.         0 iGOP STORE
  498.         "attr(A:->currentfrm)" EVAL mympegsPat LEN MOD   ( offset for GOPs put on stack
  499.         "attr(A:->currentfrm)" EVAL iStartFrm STORE
  500.  
  501.         UI_Done iCheck UICB_Checked mympegaCheck1 FETCH UI_GETATTRS
  502.         iCheck FETCH IF
  503.             "FCGOPs" "anim" DATABASE A.sFRAMECMD + CPY  ( set framecommand )
  504.         ELSE
  505.             "FCnoGOPs" "anim" DATABASE A.sFRAMECMD + CPY  ( set framecommand )
  506.         ENDIF
  507.     ENDIF
  508.  
  509.     UI_Done 0 UI_Disabled mympegaCB FETCH UI_SETATTRS
  510.     UI_Done 1 UI_Disabled mympegaSB FETCH UI_SETATTRS
  511.  
  512.     4 3 0 MENU        ( used PLAY this way to be able to undo it
  513. ;
  514.  
  515. : mympegcbCancel
  516.     UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  517.     5 4 0 MENU   ( Cancel all
  518.     UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  519.  
  520.     "MPEG|Pause|Delete" "Create MPEG, pause or delete everything?" GET_KEY
  521.         DUP 1 = IF ( MPEG
  522.             iCheck FETCH IF
  523.                 DROP ( the 1 is droped
  524.                 mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM   ( delete pictures only
  525.                 mympegsPFull "r3d3:Accessories/mpeg_encodes -combine_gops %sPARAM" sBuff SPRINTF sBuff SYSTEM
  526.                 mympegsMFull "c:delete %s.gop.#? force >nil:" sBuff SPRINTF sBuff SYSTEM
  527.                 mympegsPFull "c:delete %sPARAM force >nil:" sBuff SPRINTF sBuff SYSTEM
  528.                 sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  529.                 DROP ( offset for GOPs is droped
  530.                 QUIT
  531.             ELSE
  532.                 "attr(A:->currentfrm)" EVAL iStartFrm FETCH -
  533.                 mympegsPFull "r3d3:Accessories/mpeg_encodes -frames 0 %d %sPARAM" sBuff SPRINTF sBuff SYSTEM
  534.                 mympegsPFull "r3d3:Accessories/mpeg_encodes -combine_frames %sPARAM" sBuff SPRINTF sBuff SYSTEM
  535.                 mympegsPFull "c:delete %sPARAM force >nil:" sBuff SPRINTF sBuff SYSTEM
  536.                 mympegsMFull "c:delete %s.frame.#? >nil:" sBuff SPRINTF sBuff SYSTEM
  537.                 sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  538.                 "OK|No" "Delete the picture files?" GET_KEY
  539.                 IF
  540.                     mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  541.                 ENDIF
  542.                 QUIT
  543.             ENDIF
  544.         ENDIF
  545.         DUP 2 = IF ( Pause
  546.             "You selected Pause, so you may start again later." PUTS
  547.             DROP        ( the 2 is droped, offset for GOPs is left on the stack
  548.             EXIT
  549.         ENDIF
  550.         0 = IF  ( Delete
  551.             mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM           ( delete pictures only
  552.             mympegsMFull "c:delete %s.gop.#? force >nil:" sBuff SPRINTF sBuff SYSTEM
  553.             mympegsPFull "c:delete %sPARAM force >nil:" sBuff SPRINTF sBuff SYSTEM
  554.             QUIT ( also empty stack
  555.         ENDIF
  556. ;
  557.  
  558. : mympegcbHelp
  559.     "r3d3:help/mympeg_gui.guide" "Introduction" 0 AGUIDE
  560. ;
  561.  
  562. : mympegcbClose
  563.     mympegsStrV LEN IF
  564.         mympegsStrV iOutput FETCH "attr(W:%s->output)=%d" sBuff SPRINTF  sBuff EVAL DROP  ( restore original outputmodes
  565.         sFrmCmd "anim" DATABASE A.sFRAMECMD + CPY  ( restore original framecommand
  566.     ENDIF
  567.     mympegaWindow FETCH UI_DELETE   ( delete the window
  568.     NULL mympegaWindow STORE        ( Set mympegaWindow to NULL
  569.     ( REFRESH
  570.     ( FORGET MyMPEG_GUI
  571. ;
  572.  
  573.  
  574. ( Callback for Window. Mouse movements, mouse clicks and close window
  575. ( events are reported.
  576.  
  577. : mympegcbWindow
  578.     PARAM
  579.         VARIABLE iMouseY
  580.         VARIABLE iMouseX
  581.         VARIABLE iEvent
  582.     ENDPARAM
  583.  
  584.     ( Check if iEvent is equal to UIWM_Close
  585.     iEvent FETCH UIWM_Close =
  586.     IF
  587.        ( & ) mympegcbClose ( EXECUTE )
  588.     ENDIF
  589. ;
  590.  
  591. ?ENDIF
  592.  
  593.  
  594. ( Now that we have defined all the required variables and words it is time
  595. ( to create windows and other display elements.
  596.  
  597. ( if window is already open, prompt proper error message and do nothing.
  598. mympegaWindow FETCH
  599.  
  600. ?IF
  601.     "Understood" "Window already opened" GET_KEY DROP
  602. ?ELSE
  603.  
  604.     ( otherwise, open all display elements
  605.  
  606.     ( Open a window
  607.     UI_Done & mympegcbWindow 0 0 326 FONTSIZE 107 + "MyMPEG ©1997 Marc Bartels" UI_WINDOW mympegaWindow STORE
  608.  
  609.     ( create button gadgets, no need to save handles ?
  610.  
  611.     UI_Done mympegaWindow FETCH 0 86 FONTSIZE 5 + 0 12 "Memory  :" UI_TEXT DROP
  612.     UI_Done
  613.     1 UICB_Checked
  614.     mympegaWindow FETCH & mympegcbCheck1 86 FONTSIZE 5 + 50 12 "use GOPs" UI_CHECKBOX mympegaCheck1 STORE
  615.     UI_Done
  616.     0 UICB_Checked
  617.     mympegaWindow FETCH & mympegcbCheck2 86 FONTSIZE 17 + 50 12 "do not use GOPs" UI_CHECKBOX mympegaCheck2 STORE
  618.  
  619.  
  620.     7 PARRAY mympegLab1
  621.     0 "custom" "320 × 256" "352 × 240" "160 × 128" "160 × 112" "128 ×  96" mympegLab1 PINIT
  622.     UI_Done
  623.     1 UIMX_Active
  624.     160 mympegiStrX STORE 112  mympegiStrY STORE
  625.     mympegLab1 UIMX_Labels
  626.     mympegaWindow FETCH & mympegcbMx1 86 FONTSIZE 29 + 108 12 "Size    :" UI_MX mympegaMx1 STORE
  627.  
  628.     UI_Done
  629.     mympegaWindow FETCH & mympegcbStrX 232 FONTSIZE 29 + 44 12 "X Y" UI_STRING mympegaStrX STORE
  630.  
  631.     UI_Done
  632.     mympegaWindow FETCH & mympegcbStrY 276 FONTSIZE 29 + 44 12 "" UI_STRING mympegaStrY STORE
  633.  
  634.  
  635.     6 PARRAY mympegLab2
  636.     0 "custom" "IBBPBBI" "IBP" "IPBP" "IIII" mympegLab2 PINIT
  637.     "IIII" mympegsPat SPRINTF
  638.     UI_Done
  639.     0 UIMX_Active
  640.     mympegLab2 UIMX_Labels
  641.     mympegaWindow FETCH & mympegcbMx2 86 FONTSIZE 41 + 100 12 "Quality :" UI_MX mympegaMx2 STORE
  642.  
  643.     UI_Done
  644.     mympegaWindow FETCH & mympegcbPat 232 FONTSIZE 41 + 88 12 "Pat." UI_STRING mympegaPat STORE
  645.  
  646.     UI_Done "2" DUP mympegsStrI CPY UIST_String
  647.     mympegaWindow FETCH & mympegcbStrI 232 FONTSIZE 53 + 28 12 "IBP" UI_STRING DROP
  648.  
  649.     UI_Done "4" DUP mympegsStrB CPY UIST_String
  650.     mympegaWindow FETCH & mympegcbStrB 262 FONTSIZE 53 + 28 12 "" UI_STRING DROP
  651.  
  652.     UI_Done "6" DUP mympegsStrP CPY UIST_String
  653.     mympegaWindow FETCH & mympegcbStrP 292 FONTSIZE 53 + 28 12 "" UI_STRING DROP
  654.     
  655.  
  656.     CountView 2 + PARRAY mympegLab3
  657.     0 CycleView "(None)" mympegLab3 PINIT
  658.     UI_Done
  659.     0 UIMX_Active
  660.     mympegLab3 UIMX_Labels
  661.     mympegaWindow FETCH & mympegcbMx3 86 FONTSIZE 53 + 100 12 "Window  :" UI_MX mympegaMx3 STORE
  662.  
  663.     UI_Done
  664.     mympegaWindow FETCH & mympegcbPic 86 FONTSIZE 65 + 206 12 "Pictures:" UI_STRING mympegaPic STORE
  665.  
  666.     UI_Done
  667.     mympegaWindow FETCH & mympegcbGetP 292 FONTSIZE 65 + 28 12 "/\\" UI_BUTTON mympegaPB STORE
  668.  
  669.  
  670.     UI_Done
  671.     mympegaWindow FETCH & mympegcbMPG 86 FONTSIZE 77 + 206 12 "MPEGfile:" UI_STRING mympegaMPG STORE
  672.  
  673.     UI_Done
  674.     mympegaWindow FETCH & mympegcbGetM 292 FONTSIZE 77 + 28 12 "/\\" UI_BUTTON mympegaMB STORE
  675.  
  676.  
  677.     UI_Done mympegaWindow FETCH & mympegcbStart   6 FONTSIZE 91 + 75 12 "Start"  UI_BUTTON mympegaSB STORE
  678.     UI_Done mympegaWindow FETCH & mympegcbCancel 85 FONTSIZE 91 + 75 12 "Cancel" UI_BUTTON mympegaCB STORE
  679.     UI_Done mympegaWindow FETCH & mympegcbHelp  166 FONTSIZE 91 + 75 12 "Help"   UI_BUTTON DROP
  680.     UI_Done mympegaWindow FETCH & mympegcbClose 245 FONTSIZE 91 + 75 12 "Close"  UI_BUTTON DROP
  681.  
  682.     
  683.     mympegaWindow FETCH UI_REALIZE         ( realize display elements
  684.  
  685. ?ENDIF
  686. UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  687. UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  688. UI_Done 1 UI_Disabled mympegaPat FETCH UI_SETATTRS
  689. UI_Done 1 UI_Disabled mympegaPic FETCH UI_SETATTRS
  690. UI_Done 1 UI_Disabled mympegaPB FETCH UI_SETATTRS
  691. UI_Done 1 UI_Disabled mympegaMPG FETCH UI_SETATTRS
  692. UI_Done 1 UI_Disabled mympegaMB FETCH UI_SETATTRS
  693. UI_Done 1 UI_Disabled mympegaSB FETCH UI_SETATTRS
  694. UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  695.  
  696.  
  697. ( FORGET MyMPEG_GUI
  698.